import { Global } from "../../../../com/gengine/global/Global";
type int = number;
//class UiFlyDispalyObjectUtil
    
    export  class UiFlyDispalyObjectUtil
    {
        constructor()
        {
            
            this._objectArray = [];
            if (UiFlyDispalyObjectUtil._instance != null) 
            {
                throw new Error("UiFlyDispalyObjectUtil单例");
            }
            return;
        }

        public getPoint(arg1: Object /* flash.display.DisplayObject */): Object /* flash.geom.Point */
        {
            var loc2=null;
            var loc3=0;
            var loc5=0;
            this._objectNum = this._objectNum + 1;
            var loc1=false;
            var loc9=0;
            var loc10=this._objectArray;
            for(loc2 of loc10) 
            {
                if (loc2 != arg1) 
                {
                    continue;
                }
                loc1 = true;
            }
            if (!loc1) 
            {
                this._objectArray.push(arg1);
            }
            var loc4=0;
            while (loc4 < (this._objectArray.length - 1)) 
            {
                if (this._objectArray[loc4] != null) 
                {
                    loc3 = loc3 + 70;
                }
                ++loc4;
            }
            var loc6=150;
            var loc7=0;
            while (loc7 < this._objectArray.length) 
            {
                if (this._objectArray[loc7] != null) 
                {
                    loc2 = this._objectArray[loc7] as Object /* flash.display.DisplayObject */;
                    loc5 = (Global.stage.stageWidth - loc3) / 2 + 70 * loc7;
                    if (loc7 < (this._objectArray.length - 1)) 
                    {
                        loc2.x = loc5;
                        loc2.y = loc6;
                    }
                }
                ++loc7;
            }
            var loc8;
            return loc8 = new Object /* flash.geom.Point */(loc5, loc6);
        }

        public reducePoint(arg1: Object /* flash.display.DisplayObject */): void
        {
            var loc1=this._objectArray.indexOf(arg1);
            if (loc1 != -1) 
            {
                --this._objectNum;
                this._objectArray.splice(loc1, 1);
                this.resetPoints();
            }
            return;
        }

        public resetPoints(): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=0;
            var loc2=0;
            while (loc2 < (this._objectArray.length - 1)) 
            {
                if (this._objectArray[loc2] != null) 
                {
                    loc1 = loc1 + 70;
                }
                ++loc2;
            }
            var loc5=150;
            var loc6=0;
            while (loc6 < this._objectArray.length) 
            {
                if (this._objectArray[loc6] != null) 
                {
                    loc3 = this._objectArray[loc6] as Object /* flash.display.DisplayObject */;
                    loc4 = (Global.stage.stageWidth - loc1) / 2 + 70 * loc6;
                    loc3.x = loc4;
                    loc3.y = loc5;
                }
                ++loc6;
            }
            return;
        }

        public static get instance(): UiFlyDispalyObjectUtil
        {
            if (UiFlyDispalyObjectUtil._instance == null) 
            {
                UiFlyDispalyObjectUtil._instance = new UiFlyDispalyObjectUtil();
            }
            return UiFlyDispalyObjectUtil._instance;
        }

        /* internal */ /* var */_objectNum: int=0;

        /* internal */ /* var */_objectArray: Array<any>;

        /* internal */ /* var */_gap: number=10;

        /* internal */ static /* var */_instance: UiFlyDispalyObjectUtil;
    }
